/**
 * related to home_pop.ui
 * 
 * @Author : 879524708@qq.com
 * @Timestamp : 2016-06-14
 */

var page = sm('do_Page');
var app = sm("do_App");
var nf = sm("do_Notification");

//定义按钮全局变量
var mainInterface=ui("do_ALayout_b1");
var member = ui("do_ALayout_b2")
var statistics = ui("do_ALayout_b3")
var setting = ui("do_ALayout_b4");

var do_ImageView_b1 = ui("do_ImageView_b1");
var do_ImageView_b2 = ui("do_ImageView_b2");
var do_ImageView_b3 = ui("do_ImageView_b3");
var do_ImageView_b4 = ui("do_ImageView_b4");
var search = ui("search");

var do_Label_b1 = ui("do_Label_b1");
var do_Label_b2 = ui("do_Label_b2");
var do_Label_b3 = ui("do_Label_b3");
var do_Label_b4 = ui("do_Label_b4");


//实例化view_show 组件
var do_view_show = ui("do_ViewShower_main");
var title = ui("header_title");


//绑定数据
var viewshow  = [{
		"id":"main",
		"path":"source://view/main/main.ui",
	}, {
		"id":"member",
		"path":"source://view/member/main.ui"
	},{
		"id":"statistics",
		"path":"source://view/datashow/main.ui"
	},{
		"id":"setting",
		"path":"source://view/settings/main.ui"
	}]
do_view_show.addViews(viewshow);

//在登录成功取账号数值





//在主页新闻界面，月报统计界面，点击月报，传值过来判断默认界面
var a = page.getData();
if(a == "monthlyreport"){
	do_view_show.showView("statistics");
} else {
	search.visible = false;
	do_view_show.showView("main");
}


mainInterface.on("touch", function() {
	do_ImageView_b1.source = "source://image/icons/home_black.png";
	do_ImageView_b2.source = "source://image/icons/member_white.png";
	do_ImageView_b3.source = "source://image/icons/statistics_white.png";
	do_ImageView_b4.source = "source://image/icons/setting_white.png";
	do_Label_b1.fontColor = "2C2C2CFF";
	do_Label_b2.fontColor = "FFFFFFFF";
	do_Label_b3.fontColor = "FFFFFFFF";
	do_Label_b4.fontColor = "FFFFFFFF";
	search.visible = false;
	title.text = "收银台";
	do_view_show.showView("main");
	
});
member.on("touch", function() {
	do_ImageView_b1.source = "source://image/icons/home_white.png";
	do_ImageView_b2.source = "source://image/icons/member_black.png";
	do_ImageView_b3.source = "source://image/icons/statistics_white.png";
	do_ImageView_b4.source = "source://image/icons/setting_white.png";
	do_Label_b1.fontColor = "FFFFFFFF";
	do_Label_b2.fontColor = "2C2C2CFF";
	do_Label_b3.fontColor = "FFFFFFFF";
	do_Label_b4.fontColor = "FFFFFFFF";
	search.visible = true;
	title.text = "会员";
	do_view_show.showView("member");
	
});
statistics.on("touch", function() {
	do_ImageView_b1.source = "source://image/icons/home_white.png";
	do_ImageView_b2.source = "source://image/icons/member_white.png";
	do_ImageView_b3.source = "source://image/icons/statistics_black.png";
	do_ImageView_b4.source = "source://image/icons/setting_white.png";
	do_Label_b1.fontColor = "FFFFFFFF";
	do_Label_b2.fontColor = "FFFFFFFF";
	do_Label_b3.fontColor = "2C2C2CFF";
	do_Label_b4.fontColor = "FFFFFFFF";
	title.text = "统计";
	search.visible = false;
	do_view_show.showView("statistics");
	
});
setting.on("touch", function() {
	do_ImageView_b1.source = "source://image/icons/home_white.png";
	do_ImageView_b2.source = "source://image/icons/member_white.png";
	do_ImageView_b3.source = "source://image/icons/statistics_white.png";
	do_ImageView_b4.source = "source://image/icons/setting_black.png";
	do_Label_b1.fontColor = "FFFFFFFF";
	do_Label_b2.fontColor = "FFFFFFFF";
	do_Label_b3.fontColor = "FFFFFFFF";
	do_Label_b4.fontColor = "2C2C2CFF";
	title.text = "设置";
	search.visible = false;
	do_view_show.showView("setting");
});

//物理按键返回
page.on("back", function(data) {
	app.closePage();
})




